package demo.api.trustsign;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

import util.HttpClientUtil;
/**
 * 4.10	吊销数字证书
 * 吊销（作废）用户的数字证书。
 * @throws IOException
 */
public class CertificateRevoke {
	private static String appKey = "cAwut4VATycNMq17NZeFUD63pe83l2OJ";
    private static String appSecrty = "3BAlrfr7lW8kwlCMfo1dXS8Syn5q5qjS";
    private static String baseUrl = "http://smp-test.szitrus.com.cn/smp-api";
    private static String api = "/api/trustsign/certificate/revoke";//该接口 v2.8版本新增，测试环境未迭代

	public static void main(String[] args) throws IOException {
		String url = baseUrl.concat(api);
	    // 请求参数
		Map<String, String> params = new HashMap<>();
	    params.put("user_id", "2");
	    params.put("cert_serialnumber", "147116D26DC4FCE532B2ED3B71A865C9A3FB3C58");//数字证书序列号
        params.put("revoke_reason", "unspecified"); // 吊销理由，有以下固定值："unspecified" 未指定, "keyCompromise" 密钥泄露, "caCompromise" CA泄露, "affiliationChanged" 附属关系已改变, "superseded" 被取代, "cessationOfOperation" 停止操作

	    String resStr =  HttpClientUtil.getResponse(url, params, appKey, appSecrty);
	    JSONObject resJson = JSON.parseObject(resStr);	
	    System.out.println(resJson);
	}
}
